uniform mat4 boneTransforms[48];
uniform float time;

int bones[4];
float weights[4];

float pointSize(vec4 loc)
{
float ptSize = length(loc);
return (10000.0/ptSize);
}



void seperateBoneInfluences(){

bones[0]=int(gl_Color.x);
bones[1]=int(gl_Color.y);
bones[2]=int(gl_Color.z);
bones[3]=int(gl_Color.w);

weights[0]=gl_SecondaryColor.x;
weights[1]=gl_SecondaryColor.y;
weights[2]=gl_SecondaryColor.z;
weights[3]=gl_SecondaryColor.w;
}

void main(){

gl_FrontColor=vec4(gl_MultiTexCoord0.x, gl_MultiTexCoord0.y, gl_MultiTexCoord0.z,1.0);

seperateBoneInfluences();

vec4 myVertex=gl_Vertex;
myVertex.w=1.0;
mat4 myMat=mat4(0.0);



//apply bone transformations
for (int i=0; i< 4; i++){
        myMat+= boneTransforms[bones[i]] *  weights[i];
    }

//combine with ModelView Matrix, etc...
mat4 localWorld= myMat;

vec4 world=localWorld* myVertex;

gl_Position=gl_ProjectionMatrix * world;

float particleScale=1.0;
particleScale=gl_Vertex.w * 0.15 * gl_Position.w ;

gl_PointSize=pointSize(gl_Position)* particleScale;

}




